///////////////////////////////////////////////////////////////////////////////
// Project: Hoyo Client Game
//
// hy_message_dispersed_center.h
// Created: 2012-10-26
// Author: Like Cheng
///////////////////////////////////////////////////////////////////////////////
#pragma once
#include "hy_includes.h"
#ifndef __HY_MESSAGE_DISPERSED_CENTER_H_
#define __HY_MESSAGE_DISPERSED_CENTER_H_


typedef bool ( hy_object::*game_interface_handler_t )( void* );
typedef bool ( *game_interface_handler_static_t )( void* );

struct exec_handle
{
	exec_handle(){ m_target = NULL;m_handler = NULL;}
	hy_object*					m_target;
	game_interface_handler_t	m_handler;
};

class hy_message_dispersed_center
{
public:
	hy_message_dispersed_center();
	virtual ~hy_message_dispersed_center();

	static hy_message_dispersed_center*			instance();
	static void									purge_instance();

	void		init_message();
	void		init_handle_message();
	void		message_dispersed( void *msg );
	void		exec_message_map( int id, void* msg );

	void		reg_message_map( int id, game_interface_handler_static_t function_p );
	void		reg_message_handle_map( int id, hy_object* tag, game_interface_handler_t function_p );

	typedef map< int, game_interface_handler_static_t >		message_map;
	typedef std::map< int, exec_handle* >					message_handle_map;

private:
	message_map					m_message_map;
	message_handle_map			m_message_handle_map;
};

#endif